#!/usr/bin/python


from nagiosconfig import hostgroups

for name, props in hostgroups.iteritems():
    if len(props['members']) == 0:
        continue
    print """
        define hostgroup {
            hostgroup_name %s
            alias %s
            members %s
            %s
        }
        """ % (name,
               props['alias'],
               ",".join(props['members']),
               ["", "contact_groups "]['contact_groups' in props] + props.get('contact_groups', '')
              )

